﻿<UserControl x:Class="CodeC.UI.View.CodeCView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:converter="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"
             xmlns:controls="clr-namespace:CodeC.Infrastructure.Controls;assembly=CodeC.Infrastructure"
             mc:Ignorable="d" MinWidth="410"
             d:DesignHeight="300" d:DesignWidth="600">
    <UserControl.InputBindings>
        <KeyBinding Modifiers="Alt" Key="R" Command="{Binding RunCommand}"></KeyBinding>
        <KeyBinding Modifiers="Alt" Key="C" Command="{Binding SaveCommand}"></KeyBinding>
        <KeyBinding Modifiers="Alt" Key="L" Command="{Binding DeleteCommand}"></KeyBinding>
    </UserControl.InputBindings>
    <UserControl.Resources>
        <ResourceDictionary>

            <converter:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"></converter:BooleanToVisibilityConverter>
         

            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/CodeC.UI;component/Resources/Style.xaml"></ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="24"></RowDefinition>
            <RowDefinition MinHeight="20"></RowDefinition>
            <RowDefinition Height="5"></RowDefinition>
            <RowDefinition MinHeight="20"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Background="#FFBCC7D8">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="25" ></ColumnDefinition>
                <ColumnDefinition Width="1"></ColumnDefinition>
                <ColumnDefinition Width="85"></ColumnDefinition>
                <ColumnDefinition Width="200"></ColumnDefinition>
                <ColumnDefinition Width="25"></ColumnDefinition>
                <ColumnDefinition Width="1"></ColumnDefinition>
                <ColumnDefinition Width="25"></ColumnDefinition>
                <ColumnDefinition Width="1"></ColumnDefinition>
                <ColumnDefinition Width="170"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Button x:Name="btnRun"  Command="{Binding RunCommand}" ToolTip="Run (Alt+R)" Grid.Column="0" Width="24" Height="24"  Style="{DynamicResource IconButtonStyle}" >
                <Image  Width="16" Height="16" Source="/CodeC.UI;component/Images/FormRunHS.png" />
            </Button>
            <Border Grid.Column="1" Margin="0,2" Background="#FF878D95"></Border>
            <TextBlock Text="Manage Code: " Grid.Column="2" VerticalAlignment="Center" Margin="5,0,0,0" Foreground="#FF2E2E31"></TextBlock>
            <!--Style="{StaticResource CodeCComboBox}"-->
            <controls:CodeCComboBox ItemsSource="{Binding ListOfFileModel}"
                 
                      DisplayMemberPath="Name"
                      Text="{Binding NewName, UpdateSourceTrigger=LostFocus}"
                      SelectedItem="{Binding FileModel,Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
                      IsEditable="True" Grid.Column="3" Margin="5,0,0,0" Height="20" Background="#FFF1F3F8" Padding="3,1,3,1" BorderBrush="#FF6B6E6F">
            </controls:CodeCComboBox>

            <Button Command="{Binding SaveCommand}" ToolTip="Save (Alt+C)" Grid.Column="4" Width="25" Height="24"  Style="{DynamicResource IconButtonStyle}" >
                <Image  Width="16" Height="16"  Margin="-2,-2,0,0" Source="/CodeC.UI;component/Images/saveHS.png" />
            </Button>
            <Border Grid.Column="5" Margin="0,2" Background="#FF878D95"></Border>

            <Button Command="{Binding DeleteCommand}" ToolTip="Delete (Alt+L)" Grid.Column="6" Width="24" Height="24"  Style="{DynamicResource IconButtonStyle}">
                <Image  Width="16" Height="16" Source="/CodeC.UI;component/Images/DeleteHS.png" />
            </Button>
            <Border Grid.Column="7" Margin="0,2" Background="#FF878D95"></Border>
            <CheckBox Style="{StaticResource checkboxLeftSideText}" Grid.Column="8" IsChecked="{Binding IsExcludeProjectReference}" Content="Exclude Project References: " 
                      IsEnabled="{Binding ElementName=btnRun, Path=IsEnabled}" VerticalAlignment="Center"  Margin="5,0,0,0" Foreground="#FF2E2E31"></CheckBox>
        </Grid>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="20"></ColumnDefinition>
                <ColumnDefinition Width="5"></ColumnDefinition>
                <ColumnDefinition MinWidth="20"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <TextBox x:Name="txtMain" ToolTip="Main Code"
                     Text="{Binding MainCode, UpdateSourceTrigger=PropertyChanged}"
                     Grid.Column="0" 
                     VerticalScrollBarVisibility="Auto" 
                     HorizontalScrollBarVisibility="Auto"
                     AcceptsTab="True" 
                     AcceptsReturn="True"
                     BorderThickness="0"></TextBox>
            <GridSplitter
                ResizeDirection="Columns"
                Grid.Column="1"              
                Width="5"
                Height="Auto"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                Margin="0"
                Background="#FF293955"/>

            <TextBox x:Name="txtClassMethods" ToolTip="Properties, Methods and Sub Classes"
                     Text="{Binding ClassMethodsCode}" 
                     Grid.Column="2"
                     HorizontalScrollBarVisibility="Auto"
                     VerticalScrollBarVisibility="Auto" 
                     AcceptsTab="True" 
                     AcceptsReturn="True"
                     BorderThickness="0"
                     ></TextBox>
        </Grid>
        <GridSplitter
                ResizeDirection="Rows"
                Grid.Row="2"              
                Width="Auto"
                Height="5"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                Margin="0" 
                Background="#FF293955"/>
        <Grid Grid.Row="3">
            <TextBox Text="{Binding Result}" 
                     Grid.Column="0" 
                     Visibility="{Binding IsResult, Converter={StaticResource BooleanToVisibilityConverter}}"
                     IsReadOnly="True"
                     HorizontalScrollBarVisibility="Auto"
                     VerticalScrollBarVisibility="Auto" 
                     BorderThickness="0"
                     ></TextBox>
            <!--BooleanToVisibilityConverter-->
            <Grid Grid.Column="0" Visibility="{Binding IsError, Converter={StaticResource BooleanToVisibilityConverter}}" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="16"></RowDefinition>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                <Grid Grid.Row="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="100"></ColumnDefinition>
                        <ColumnDefinition Width="50"></ColumnDefinition>
                        <ColumnDefinition Width="100"></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Section" Grid.Column="0"></TextBlock>
                    <TextBlock Text="Line" Grid.Column="1"></TextBlock>
                    <TextBlock Text="Number" Grid.Column="2"></TextBlock>
                    <TextBlock Text="Description" Grid.Column="3"></TextBlock>
                </Grid>
                <controls:CodeCListBox  Grid.Row="1" ItemsSource="{Binding ListOfError}" SelectedItem="{Binding SelectedErrorModel}" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" BorderThickness="0">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="100"></ColumnDefinition>
                                    <ColumnDefinition Width="50"></ColumnDefinition>
                                    <ColumnDefinition Width="100"></ColumnDefinition>
                                    <ColumnDefinition></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="{Binding Section}" Grid.Column="0"></TextBlock>
                                <TextBlock Text="{Binding Line}" Grid.Column="1"></TextBlock>
                                <TextBlock Text="{Binding Number}" Grid.Column="2"></TextBlock>
                                <TextBlock Text="{Binding Text}" Grid.Column="3"></TextBlock>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </controls:CodeCListBox>

            </Grid>

        </Grid>

    </Grid>
</UserControl>
